package com.fortune.rainshineservice.controller;

import com.fortune.rainshinecommon.base.MsgModel;
import com.fortune.rainshinecommon.base.ParmsModel;
import com.fortune.rainshinecommon.model.ProductModel;
import com.fortune.rainshinecommon.query.ProductQuery;
import com.fortune.rainshineservice.service.IproductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: rainShine
 * @description: 产品控制器
 * @author: tangyn
 * @create: 2019-02-23
 **/
@RestController
@RequestMapping("/product")
public class ProductController {

    @Autowired
    private IproductService iproductService;

    @PostMapping("/createProduct")
    public MsgModel createProduct(@RequestBody ProductModel productModel){
        return iproductService.createProduct(productModel);
    }

    @PostMapping("/updateProduct")
    public MsgModel updateProduct(@RequestBody ProductModel productModel){
        return iproductService.updateProduct(productModel, "test");
    }

    @PostMapping("/productList")
    public MsgModel productList(@RequestBody ParmsModel parm){
        return iproductService.productList(parm);
    }

    @PostMapping("/delProduct")
    public MsgModel delProduct(@RequestBody ProductModel productModel){
        return iproductService.delProduct(productModel);
    }
    
    @PostMapping("/update")
    public MsgModel update(@RequestBody ProductModel productModel){
        return iproductService.update(productModel);
    }

    @PostMapping("/appGetProductInfo")
    public MsgModel appGetProductInfo(@RequestBody ProductQuery query){
        return iproductService.getProductInfo(query.getId());
    }
}
